package com.youpingou.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.youpingou.domain.Sku;
import com.youpingou.domain.Specification;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface SpecificationMapper extends BaseMapper<Specification> {

    @Select("select * from tb_specification where id = #{specId}")
    @Results({
            @Result(column = "id",property = "id"),
            @Result(column = "spec_name",property = "specName"),
            @Result(column = "category_id",property = "categoryId"),
            @Result(column = "id",property = "options",many = @Many(select = "com.youpingou.mapper.SpecificationOptionMapper.findSpecificationOptionBySpecid"))
    })
    public Specification findSpecificationBySpecid(Integer specId);



    @Select("select * from tb_specification where category_id = #{cat3id}")
    @Results({
            @Result(column = "id",property = "id"),
            @Result(column = "spec_name",property = "specName"),
            @Result(column = "category_id",property = "categoryId"),
            @Result(column = "id",property = "options",many = @Many(select = "com.youpingou.mapper.SpecificationOptionMapper.findSpecificationOptionBySpecId")),
    })
    public List<Specification> findSpecificationByCat3id(Integer cat3id);


}
